package com.day1;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;
@WebFilter(filterName = "filter1",value = "/*")
public class Filter1 implements Filter{
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("这是inint1======");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
    servletRequest.setCharacterEncoding("utf-8");
    servletResponse.setContentType("text/html;charset=utf-8");
        System.out.println("这是dofilter1=====");
        //放行：
    filterChain.doFilter(servletRequest,servletResponse);
        System.out.println("selvlet1结束");

    }

    @Override
    public void destroy() {
        System.out.println("这是destory1======");
    }
}
